package com.xyht.sca_s.student_manage_system.modules.welcomeNewStudent.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.welcomeNewStudent.entity.req.SmsWnsInformationConsultReq;
import com.xyht.sca_s.student_manage_system.modules.welcomeNewStudent.service.SmsWnsInformationConsultService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 信息咨询群表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2024-01-25
 */
@RestController
@RequestMapping("/welcomeNewStudent/informationConsult")
@SecretBody
public class SmsWnsInformationConsultController {

    @Resource
    private JwtTokenUtil jwtTokenUtil;
    @Resource
    private SmsWnsInformationConsultService smsWnsInformationConsultService;

    @ApiOperation("添加信息咨询群")
    @PostMapping("/add")
    public ResponseResult addInformationConsult(HttpServletRequest request, @RequestBody SmsWnsInformationConsultReq addReq) {
        String userId = jwtTokenUtil.getUserIdByRequest(request);
        return smsWnsInformationConsultService.addInformationConsult(userId,addReq);
    }

    @ApiOperation("删除信息咨询群")
    @PostMapping("/deleted")
    public ResponseResult deletedInformationConsult(@RequestBody SmsWnsInformationConsultReq deletedReq) {
        return smsWnsInformationConsultService.deletedInformationConsult(deletedReq);
    }

    @ApiOperation("修改信息咨询群详情")
    @PostMapping("/update")
    public ResponseResult updateInformationConsult(@RequestBody SmsWnsInformationConsultReq updateReq) {
        return smsWnsInformationConsultService.updateInformationConsult(updateReq);
    }

    @ApiOperation("获取信息咨询群详情")
    @GetMapping("/id")
    public ResponseResult getInformationConsultDetail(@RequestParam(value = "id")String id) {
        return smsWnsInformationConsultService.getInformationConsultDetail(id);
    }

    @ApiOperation("获取信息咨询群列表")
    @GetMapping("/list")
    public ResponseResult getInformationConsultList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                    @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                                    @RequestParam(value = "collegeId", required = false) String collegeId,
                                                    @RequestParam(value = "majorId", required = false) String majorId,
                                                    @RequestParam(value = "gradeId", required = false) String gradeId,
                                                    @RequestParam(value = "classId", required = false) String classId,
                                                    @RequestParam(value = "classTeacher", required = false) String classTeacher) {
        return smsWnsInformationConsultService.getInformationConsultList(collegeId,majorId,gradeId,classId,classTeacher,pageNum,pageSize);
    }

    @ApiOperation("获取自己的信息咨询群")
    @GetMapping("/myInformationConsult")
    public ResponseResult getMyInformationConsult(HttpServletRequest request) {
        String userId = jwtTokenUtil.getUserIdByRequest(request);
        return smsWnsInformationConsultService.getMyInformationConsult(userId);
    }
}

